package com.training.java.core.collections.car.post15;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class CarListDemo {

	public static void main(String[] args) {

		Car focus = new Car("Ford", "Focus", 2014, 12000);
		Car corola = new Car("Toyota", "Corola", 2013, 18000);
		Car civic = new Car("Honda", "Civic", 2014, 18000);
		
		List<Car> cars = new ArrayList<Car>();
		
		cars.add(focus);
		cars.add(corola);
		cars.add(civic);
		
		Iterator<Car> carsIterator = cars.iterator();
		
		while(carsIterator.hasNext())
		{
			Car acar =(Car) carsIterator.next();
			System.out.println("Make of the car is " + acar.getMake());
			System.out.println("Model of the car is " + acar.getModel());
			System.out.println("Year of the car is " + acar.getYear());
			System.out.println("Price of the car is " + acar.getPrice());
			System.out.println("************");
		}
		
		System.out.println("--------------------------------------------");
		for(Car acar: cars)
		{
			System.out.println("Make of the car is " + acar.getMake());
			System.out.println("Model of the car is " + acar.getModel());
			System.out.println("Year of the car is " + acar.getYear());
			System.out.println("Price of the car is " + acar.getPrice());
			System.out.println("************");
		}
	}

}
